<template>
  <div :class="data.name +' home-rolls'">
    <div class="rolls-wrap">
      <div class="rolls-main ">
        <div class="rolls-left fl" :style="'background: '+data.left.bg">
          <div class="rolls-title">
            <h3>{{ data.title }}</h3>
            <p>{{ data.enLang }}</p>
          </div>
          <div class="rolls-image">
            <img :src="data.image">
          </div>
          <ul class="rolls-tags">
            <li v-for="i in data.left.tags" @click="routeToPath('/search/product?kw='+i.name, 'new')">{{ i.name }}</li>
          </ul>
        </div>
        <ul class="rolls-right fl">
          <li class="rolls-item" v-for="i in goodsList" @click="routeToPath('/product/detail?id='+i.id, 'new')">
            <div class="item-pic">
              <img class="maxs" :src="URL.PIC+i.mainImgPath">
            </div>
            <div class="item-title">
              {{ i.title }}
            </div>
            <div class="item-price">
              ￥{{ i.productSpecification.sellingPrice }}
            </div>
          </li>
        </ul>
      </div>
      <div class="rolls-brand">
        <ul>
          <li v-for="i in data.brands" @click="routeToPath(i.url, 'new')">
            <img :src="i.pic">
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
  import { getRolls } from '@/api/home'
export default {
  props: ['params'],
  data() {
    return {
      data: this.params,
      hoverActive: '',
      goodsList: [],
    }
  },
  created() {
    this.getRolls(this.params);
  },
  methods: {
    getRolls(params) {
      var hostname = window.location.hostname;
      var myparams;
      // 开发环境
      if(hostname == 'dgyp.youboy.com' || hostname == 'localhost'){
         myparams = params.devItem.join(',')
      // 测试环境
      }else if(hostname == 'tgyp.youboy.com') {
        myparams = params.testItem.join(',')
      // 生产环境
      }else if(hostname == 'gyp.youboy.com') {
        myparams = params.item.join(',')
      }

      getRolls({ids: myparams}).then(res=>{
        this.goodsList = res.data;
      })
    }
  }
}
</script>

<style lang="scss" scoped>


.rolls-main{
    height: 610px;
  .rolls-left{
    padding: 60px 20px 50px 20px;
    background-color: #CDD4DA;
    height: 500px;
    width: 240px;
    border-radius: 10px;
    text-align: center;
    .rolls-title{
      h3{
        font-size: 30px;
        margin-bottom: 9px;
        margin-top: 0;
        font-weight: 500;
      }
      p{
        color: #888888;
        font-size: 16px;
        margin-top: 0;
        text-transform: uppercase;
        margin-bottom: 20px;
      }
    }
    .rolls-tags{
      margin-top: 30px;
      li{
        width: 110px;
        background-color: #4D738A;
        border-radius: 30px;
        color: #fff;
        line-height: 32px;
        float: left;
        margin-left: 20px;
        margin-bottom: 20px;
        transition: all 0.3s;
        font-size: 12px;
        cursor: pointer;
      }
      li:nth-child(odd){
        margin-left: 0;
      }
    }
  }
  .rolls-right{
    width: 920px;
    height: 620px;
    .rolls-item{
      background-color: #fff;
      padding: 10px;
      border-radius: 10px;
      width: 200px;
      height: 280px;
      float: left;
      margin-left: 10px;
      margin-bottom: 10px;
      padding-bottom: 10px;
      cursor: pointer;
      transition: all 0.4s;
      &:hover{
        box-shadow: 0 12px 36px rgba(0,0,0,0.1)
      }
      .item-pic{
        height: 200px;
        overflow: hidden;
        margin-bottom: 8px;
        // border-radius: 10px;
      }
      .item-title{
        font-size: 14px;
        color: #333;
        padding-left: 10px;
        padding-right: 10px;
        line-height: 20px;
        display: -webkit-box;
        text-align: center;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        height: 40px;
        letter-spacing: 1px;
      }
      .item-price{
        text-align: center;
        color: #D0021B;
        margin-top: 10px;
      }
    }
  }
}
.rolls-brand{
  background-color: #fff;
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
  padding-left: 30px;
  padding-right: 30px;
  li{
    border: 1px solid #eee;
    text-align: center;
    // height: 48px;
    // width: 118px;
    float: left;
    margin: 15px 0;
    transition: all 0.4s;
    cursor: pointer;
    // margin-left: 25px;
    margin-right: 46px;
    &:hover{
      box-shadow: 0 12px 36px rgba(0,0,0,0.1)
    }
    &:last-child{
      margin-right: 0;
    }
    img{
      vertical-align: middle;
      width: 100px;
      height: 45px;
    }
  }
  li:nth-child(1){
    margin-left: 0;
  }
}
.home-rolls{
  margin-bottom: 30px;
}
</style>
<style>
.rolls1 .rolls-main .rolls-left .rolls-tags li{
  background-color: #4D738A;
}
.rolls2 .rolls-main .rolls-left .rolls-tags li{
  background-color: #6CA38F;
}
.rolls3 .rolls-main .rolls-left .rolls-tags li{
  background-color: #97885B;
}

.rolls1 .rolls-main .rolls-left .rolls-tags li:hover{
  background-color: #35637F;
}
.rolls2 .rolls-main .rolls-left .rolls-tags li:hover{
  background-color: #4B8E75;
}
.rolls3 .rolls-main .rolls-left .rolls-tags li:hover{
  background-color: #87743B;
}
</style>
